<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   标签传播算法（Label Propagation）及Python实现  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/21096.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466457308: Accept with keywords: (title(0.4):Python,标签,算法,数盟,社区, topn(0.6):社区,概率,职业规划,数盟,分类器,行业资讯,类别,数据挖掘,Python,假设,模型,并行,可视化,标签,计算,文章,基础架构,数据,节点,python,步骤,样本,矩阵,算法,流形,代码,人工智能,聚类,时候,数据库).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    标签传播算法（Label Propagation）及Python实现
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    标签传播算法（Label Propagation）及Python实现 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,81] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/ai">
       人工智能
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/21096.html">
          标签传播算法（Label Propagation）及Python实现
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          1,138 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/ai" rel="category tag">
          人工智能
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        作者：
        <a href="http://my.csdn.net/zouxy09" target="_blank">
         zouxy09
        </a>
       </p>
       <p>
        众所 周知，机器学习可以大体分为三大类：监督学习、非监督学习和半监督学习。监督学习可以认为是我们有非常多的labeled标注数据来train一个模型， 期待这个模型能学习到数据的分布，以期对未来没有见到的样本做预测。那这个性能的源头–训练数据，就显得非常感觉。你必须有足够的训练数据，以覆盖真正 现实数据中的样本分布才可以，这样学习到的模型才有意义。那非监督学习就是没有任何的labeled数据，就是平时所说的聚类了，利用他们本身的数据分 布，给他们划分类别。而半监督学习，顾名思义就是处于两者之间的，只有少量的labeled数据，我们试图从这少量的labeled数据和大量的 unlabeled数据中学习到有用的信息。
       </p>
       <p>
        <strong>
         一、半监督学习
        </strong>
       </p>
       <p>
        半监督学习（Semi-supervised learning）发挥作用的场合是：你的数据有一些有label，一些没有。而且一般是绝大部分都没有，只有少许几个有label。半监督学习算法会充 分的利用unlabeled数据来捕捉我们整个数据的潜在分布。它基于三大假设：
       </p>
       <p>
        1）Smoothness平滑假设：相似的数据具有相同的label。
       </p>
       <p>
        2）Cluster聚类假设：处于同一个聚类下的数据具有相同label。
       </p>
       <p>
        3）Manifold流形假设：处于同一流形结构下的数据具有相同label。
       </p>
       <p>
        例 如下图，只有两个labeled数据，如果直接用他们来训练一个分类器，例如LR或者SVM，那么学出来的分类面就是左图那样的。如果现实中，这个数据是 右图那边分布的话，猪都看得出来，左图训练的这个分类器烂的一塌糊涂、惨不忍睹。因为我们的labeled训练数据太少了，都没办法覆盖我们未来可能遇到 的情况。但是，如果右图那样，把大量的unlabeled数据（黑色的）都考虑进来，有个全局观念，牛逼的算法会发现，哎哟，原来是两个圈圈（分别处于两 个圆形的流形之上）！那算法就很聪明，把大圈的数据都归类为红色类别，把内圈的数据都归类为蓝色类别。因为，实践中，labeled数据是昂贵，很难获得 的，但unlabeled数据就不是了，写个脚本在网上爬就可以了，因此如果能充分利用大量的unlabeled数据来辅助提升我们的模型学习，这个价值 就非常大。
       </p>
       <p align="center">
        <img src="http://img.blog.csdn.net/20151013215814223?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        半监督学习算法有很多，下面我们介绍最简单的标签传播算法（label propagation），最喜欢简单了，哈哈。
       </p>
       <p>
        <strong>
         二、标签传播算法
        </strong>
       </p>
       <p>
        标签传播算法（label propagation）的核心思想非常简单：相似的数据应该具有相同的label。LP算法包括两大步骤：1）构造相似矩阵；2）勇敢的传播吧。
       </p>
       <p>
        <strong>
         2.1、相似矩阵构建
        </strong>
       </p>
       <p>
        LP 算法是基于Graph的，因此我们需要先构建一个图。我们为所有的数据构建一个图，图的节点就是一个数据点，包含labeled和unlabeled的数 据。节点i和节点j的边表示他们的相似度。这个图的构建方法有很多，这里我们假设这个图是全连接的，节点i和节点j的边权重为：
       </p>
       <p align="center">
        <img src="http://img.blog.csdn.net/20151013215828073?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        这里，α是超参。
       </p>
       <p>
        还有个非常常用的图构建方法是knn图，也就是只保留每个节点的k近邻权重，其他的为0，也就是不存在边，因此是稀疏的相似矩阵。
       </p>
       <p>
        <strong>
         2.2、LP算法
        </strong>
       </p>
       <p>
        标签传播算法非常简单：通过节点之间的边传播label。边的权重越大，表示两个节点越相似，那么label越容易传播过去。我们定义一个NxN的概率转移矩阵P：
       </p>
       <p align="center">
        <img src="http://img.blog.csdn.net/20151013215842235?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        P
        <sub>
         ij
        </sub>
        表示从节点i转移到节点j的概率。假设有C个类和L个labeled样本，我们定义一个LxC的label矩阵Y
        <sub>
         L
        </sub>
        ，第i行表示第i个样本的标签指示向量，即如果第i个样本的类别是j，那么该行的第j个元素为1，其他为0。同样，我们也给U个unlabeled样本一个UxC的label矩阵Y
        <sub>
         U
        </sub>
        。把他们合并，我们得到一个NxC的soft label矩阵F=[Y
        <sub>
         L
        </sub>
        ;Y
        <sub>
         U
        </sub>
        ]。soft label的意思是，我们保留样本i属于每个类别的概率，而不是互斥性的，这个样本以概率1只属于一个类。当然了，最后确定这个样本i的类别的时候，是取max也就是概率最大的那个类作为它的类别的。那F里面有个Y
        <sub>
         U
        </sub>
        ，它一开始是不知道的，那最开始的值是多少？无所谓，随便设置一个值就可以了。
       </p>
       <p>
        千呼万唤始出来，简单的LP算法如下：
       </p>
       <p>
        1）执行传播：F=PF
       </p>
       <p>
        2）重置F中labeled样本的标签：F
        <sub>
         L
        </sub>
        =Y
        <sub>
         L
        </sub>
       </p>
       <p>
        3）重复步骤1）和2）直到F收敛。
       </p>
       <p>
        步 骤1）就是将矩阵P和矩阵F相乘，这一步，每个节点都将自己的label以P确定的概率传播给其他节点。如果两个节点越相似（在欧式空间中距离越近），那 么对方的label就越容易被自己的label赋予，就是更容易拉帮结派。步骤2）非常关键，因为labeled数据的label是事先确定的，它不能被 带跑，所以每次传播完，它都得回归它本来的label。随着labeled数据不断的将自己的label传播出去，最后的类边界会穿越高密度区域，而停留 在低密度的间隔中。相当于每个不同类别的labeled样本划分了势力范围。
       </p>
       <p>
        <strong>
         2.3、变身的LP算法
        </strong>
       </p>
       <p>
        我们知道，我们每次迭代都是计算一个soft label矩阵F=[Y
        <sub>
         L
        </sub>
        ;Y
        <sub>
         U
        </sub>
        ]，但是Y
        <sub>
         L
        </sub>
        是已知的，计算它没有什么用，在步骤2）的时候，还得把它弄回来。我们关心的只是Y
        <sub>
         U
        </sub>
        ，那我们能不能只计算Y
        <sub>
         U
        </sub>
        呢？Yes。我们将矩阵P做以下划分：
       </p>
       <p align="center">
        <img src="http://img.blog.csdn.net/20151013215900396?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        这时候，我们的算法就一个运算：
       </p>
       <p align="center">
        <img src="http://img.blog.csdn.net/20151013215910605?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        迭代上面这个步骤直到收敛就ok了，是不是很cool。可以看到F
        <sub>
         U
        </sub>
        不但取决于labeled数据的标签及其转移概率，还取决了unlabeled数据的当前label和转移概率。因此LP算法能额外运用unlabeled数据的分布特点。
       </p>
       <p>
        这个算法的收敛性也非常容易证明，具体见参考文献[1]。实际上，它是可以收敛到一个凸解的：
       </p>
       <p align="center">
        <img src="http://img.blog.csdn.net/20151013215922721?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        所以我们也可以直接这样求解，以获得最终的Y
        <sub>
         U
        </sub>
        。但是在实际的应用过程中，由于矩阵求逆需要O(n
        <sup>
         3
        </sup>
        )的复杂度，所以如果unlabeled数据非常多，那么I – P
        <sub>
         UU
        </sub>
        矩阵的求逆将会非常耗时，因此这时候一般选择迭代算法来实现。
       </p>
       <p>
        <strong>
         三、LP算法的Python实现
        </strong>
       </p>
       <p>
        Python 环境的搭建就不啰嗦了，可以参考前面的博客。需要额外依赖的库是经典的numpy和matplotlib。代码中包含了两种图的构建方法：RBF和KNN 指定。同时，自己生成了两个toy数据库：两条长形形状和两个圈圈的数据。第四部分我们用大点的数据库来做实验，先简单的可视化验证代码的正确性，再前 线。
       </p>
       <p>
        算法代码：
       </p>
       <div class="dp-highlighter bg_python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685cd777680356036829" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <span class="crayon-language">
            Python
           </span>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           import time
import numpy as np
# return k neighbors index
def navie_knn(dataSet, query, k):
    numSamples = dataSet.shape[0]
    ## step 1: calculate Euclidean distance
    diff = np.tile(query, (numSamples, 1)) - dataSet
    squaredDiff = diff ** 2
    squaredDist = np.sum(squaredDiff, axis = 1) # sum is performed by row
    ## step 2: sort the distance
    sortedDistIndices = np.argsort(squaredDist)
    if k &gt; len(sortedDistIndices):
        k = len(sortedDistIndices)
    return sortedDistIndices[0:k]
# build a big graph (normalized weight matrix)
def buildGraph(MatX, kernel_type, rbf_sigma = None, knn_num_neighbors = None):
    num_samples = MatX.shape[0]
    affinity_matrix = np.zeros((num_samples, num_samples), np.float32)
    if kernel_type == 'rbf':
        if rbf_sigma == None:
            raise ValueError('You should input a sigma of rbf kernel!')
        for i in xrange(num_samples):
            row_sum = 0.0
            for j in xrange(num_samples):
                diff = MatX[i, :] - MatX[j, :]
                affinity_matrix[i][j] = np.exp(sum(diff**2) / (-2.0 * rbf_sigma**2))
                row_sum += affinity_matrix[i][j]
            affinity_matrix[i][:] /= row_sum
    elif kernel_type == 'knn':
        if knn_num_neighbors == None:
            raise ValueError('You should input a k of knn kernel!')
        for i in xrange(num_samples):
            k_neighbors = navie_knn(MatX, MatX[i, :], knn_num_neighbors)
            affinity_matrix[i][k_neighbors] = 1.0 / knn_num_neighbors
    else:
        raise NameError('Not support kernel type! You can use knn or rbf!')
    return affinity_matrix
# label propagation
def labelPropagation(Mat_Label, Mat_Unlabel, labels, kernel_type = 'rbf', rbf_sigma = 1.5, \
                    knn_num_neighbors = 10, max_iter = 500, tol = 1e-3):
    # initialize
    num_label_samples = Mat_Label.shape[0]
    num_unlabel_samples = Mat_Unlabel.shape[0]
    num_samples = num_label_samples + num_unlabel_samples
    labels_list = np.unique(labels)
    num_classes = len(labels_list)
    MatX = np.vstack((Mat_Label, Mat_Unlabel))
    clamp_data_label = np.zeros((num_label_samples, num_classes), np.float32)
    for i in xrange(num_label_samples):
        clamp_data_label[i][labels[i]] = 1.0
    label_function = np.zeros((num_samples, num_classes), np.float32)
    label_function[0 : num_label_samples] = clamp_data_label
    label_function[num_label_samples : num_samples] = -1
    # graph construction
    affinity_matrix = buildGraph(MatX, kernel_type, rbf_sigma, knn_num_neighbors)
    # start to propagation
    iter = 0; pre_label_function = np.zeros((num_samples, num_classes), np.float32)
    changed = np.abs(pre_label_function - label_function).sum()
    while iter &lt; max_iter and changed &gt; tol:
        if iter % 1 == 0:
            print "---&gt; Iteration %d/%d, changed: %f" % (iter, max_iter, changed)
        pre_label_function = label_function
        iter += 1
        # propagation
        label_function = np.dot(affinity_matrix, label_function)
        # clamp
        label_function[0 : num_label_samples] = clamp_data_label
        # check converge
        changed = np.abs(pre_label_function - label_function).sum()
    # get terminate label of unlabeled data
    unlabel_data_labels = np.zeros(num_unlabel_samples)
    for i in xrange(num_unlabel_samples):
        unlabel_data_labels[i] = np.argmax(label_function[i+num_label_samples])
    return unlabel_data_labels
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-25">
                25
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-26">
                26
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-27">
                27
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-28">
                28
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-29">
                29
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-30">
                30
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-31">
                31
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-32">
                32
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-33">
                33
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-34">
                34
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-35">
                35
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-36">
                36
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-37">
                37
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-38">
                38
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-39">
                39
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-40">
                40
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-41">
                41
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-42">
                42
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-43">
                43
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-44">
                44
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-45">
                45
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-46">
                46
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-47">
                47
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-48">
                48
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-49">
                49
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-50">
                50
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-51">
                51
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-52">
                52
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-53">
                53
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-54">
                54
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-55">
                55
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-56">
                56
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-57">
                57
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-58">
                58
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-59">
                59
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-60">
                60
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-61">
                61
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-62">
                62
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-63">
                63
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-64">
                64
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-65">
                65
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-66">
                66
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-67">
                67
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-68">
                68
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-69">
                69
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-70">
                70
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-71">
                71
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-72">
                72
               </div>
               <div class="crayon-num" data-line="crayon-57685cd777680356036829-73">
                73
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777680356036829-74">
                74
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685cd777680356036829-1">
                <span class="crayon-r">
                 import
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 time
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-2">
                <span class="crayon-r">
                 import
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 numpy
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-3">
                <span class="crayon-c">
                 # return k neighbors index
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-4">
                <span class="crayon-r">
                 def
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 navie_knn
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 dataSet
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 query
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-5">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 numSamples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dataSet
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 shape
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-6">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 ## step 1: calculate Euclidean distance
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 diff
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 tile
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 query
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 numSamples
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 dataSet
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-8">
                <span class="crayon-e">
                </span>
                <span class="crayon-v">
                 squaredDiff
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 diff
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 2
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-9">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 squaredDist
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-k ">
                 sum
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 squaredDiff
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # sum is performed by row
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-10">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 ## step 2: sort the distance
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-11">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sortedDistIndices
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 argsort
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 squaredDist
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-12">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 len
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 sortedDistIndices
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-13">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 len
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 sortedDistIndices
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-14">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sortedDistIndices
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-15">
                <span class="crayon-c">
                 # build a big graph (normalized weight matrix)
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-16">
                <span class="crayon-r">
                 def
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 buildGraph
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 kernel_type
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rbf_sigma
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-t">
                 None
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 knn_num_neighbors
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-t">
                 None
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-17">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 shape
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-18">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 zeros
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 float32
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-19">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 kernel_type
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-s">
                 'rbf'
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-20">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rbf_sigma
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-t">
                 None
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-21">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 raise
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 ValueError
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-s">
                 'You should input a sigma of rbf kernel!'
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-22">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 i
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 xrange
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-23">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 row_sum
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 0.0
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-24">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 j
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 xrange
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-25">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 diff
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 j
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-26">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 j
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 exp
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-k ">
                 sum
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 diff
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 2.0
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rbf_sigma
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-27">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 row_sum
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 j
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-28">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 /=
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 row_sum
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-29">
                <span class="crayon-e">
                </span>
                <span class="crayon-st">
                 elif
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 kernel_type
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-s">
                 'knn'
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-30">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 knn_num_neighbors
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-t">
                 None
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-31">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 raise
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 ValueError
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-s">
                 'You should input a k of knn kernel!'
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-32">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 i
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 xrange
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-33">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 k_neighbors
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 navie_knn
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 knn_num_neighbors
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-34">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 k_neighbors
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 knn_num_neighbors
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-35">
                <span class="crayon-e">
                </span>
                <span class="crayon-st">
                 else
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-36">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 raise
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 NameError
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-s">
                 'Not support kernel type! You can use knn or rbf!'
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-37">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-38">
                <span class="crayon-c">
                 # label propagation
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-39">
                <span class="crayon-r">
                 def
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 labelPropagation
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 Mat_Label
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 Mat_Unlabel
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 labels
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 kernel_type
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-s">
                 'rbf'
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rbf_sigma
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1.5
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 \
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-40">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 knn_num_neighbors
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 10
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 max_iter
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 500
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tol
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1e
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-41">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # initialize
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-42">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 Mat_Label
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 shape
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-43">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_unlabel_samples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 Mat_Unlabel
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 shape
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-44">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 num_unlabel_samples
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-45">
                <span class="crayon-e">
                </span>
                <span class="crayon-v">
                 labels_list
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 unique
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 labels
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-46">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_classes
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 len
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 labels_list
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-47">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 vstack
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 Mat_Label
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 Mat_Unlabel
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-48">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 clamp_data_label
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 zeros
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_classes
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 float32
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-49">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 i
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 xrange
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-50">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 clamp_data_label
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 labels
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-51">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 zeros
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_classes
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 float32
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-52">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 clamp_data_label
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-53">
                <span class="crayon-e">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 1
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-54">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # graph construction
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-55">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 buildGraph
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 MatX
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 kernel_type
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rbf_sigma
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 knn_num_neighbors
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-56">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # start to propagation
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-57">
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 iter
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pre_label_function
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 zeros
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_samples
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_classes
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 float32
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-58">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 changed
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-k ">
                 abs
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 pre_label_function
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-k ">
                 sum
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-59">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 while
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 iter
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 max_iter
                </span>
                <span class="crayon-st">
                 and
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 changed
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tol
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-60">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 iter
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 %
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-61">
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 print
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-s">
                 "---&gt; Iteration %d/%d, changed: %f"
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 %
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-k ">
                 iter
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 max_iter
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 changed
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-62">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pre_label_function
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 label_function
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-63">
                <span class="crayon-e">
                </span>
                <span class="crayon-k ">
                 iter
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-cn">
                 1
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-64">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # propagation
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-65">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 dot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 affinity_matrix
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-66">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # clamp
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-67">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 clamp_data_label
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-68">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # check converge
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-69">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 changed
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-k ">
                 abs
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 pre_label_function
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-k ">
                 sum
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-70">
                <span class="crayon-h">
                </span>
                <span class="crayon-c">
                 # get terminate label of unlabeled data
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-71">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 unlabel_data_labels
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 zeros
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_unlabel_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-72">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 i
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-k ">
                 xrange
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 num_unlabel_samples
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685cd777680356036829-73">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 unlabel_data_labels
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 argmax
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 label_function
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 i
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-v">
                 num_label_samples
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685cd777680356036829-74">
                <span class="crayon-h">
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 unlabel_data_labels
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.1416 seconds] -->
        <br/>
        <p>
        </p>
       </div>
       <p>
        测试代码：
       </p>
       <div class="dp-highlighter bg_python">
        <div class="bar">
         <div class="tools">
          <p>
           <b>
            [python]
           </b>
           <a class="ViewSource" href="http://blog.csdn.net/zouxy09/article/details/49105265" title="view plain">
            view plain
           </a>
           <a class="CopyToClipboard" href="http://blog.csdn.net/zouxy09/article/details/49105265" title="copy">
            copy
           </a>
          </p>
          <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
          <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685cd777696947794772" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
           <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <span class="crayon-title">
            </span>
            <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-wrap-button" title="切换自动换行">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-expand-button" title="点击展开代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-copy-button" title="复制代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <span class="crayon-language">
              Python
             </span>
            </div>
           </div>
           <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
           </div>
           <div class="crayon-plain-wrap">
            <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
             #***************************************************************************
#* 
#* Description: label propagation
#* Author: Zou Xiaoyi (zouxy09@qq.com)
#* Date:   2015-10-15
#* HomePage: http://blog.csdn.net/zouxy09
#* 
#**************************************************************************

import time
import math
import numpy as np
from label_propagation import labelPropagation

# show
def show(Mat_Label, labels, Mat_Unlabel, unlabel_data_labels):
    import matplotlib.pyplot as plt

    for i in range(Mat_Label.shape[0]):
        if int(labels[i]) == 0:
            plt.plot(Mat_Label[i, 0], Mat_Label[i, 1], 'Dr')
        elif int(labels[i]) == 1:
            plt.plot(Mat_Label[i, 0], Mat_Label[i, 1], 'Db')
        else:
            plt.plot(Mat_Label[i, 0], Mat_Label[i, 1], 'Dy')

    for i in range(Mat_Unlabel.shape[0]):
        if int(unlabel_data_labels[i]) == 0:
            plt.plot(Mat_Unlabel[i, 0], Mat_Unlabel[i, 1], 'or')
        elif int(unlabel_data_labels[i]) == 1:
            plt.plot(Mat_Unlabel[i, 0], Mat_Unlabel[i, 1], 'ob')
        else:
            plt.plot(Mat_Unlabel[i, 0], Mat_Unlabel[i, 1], 'oy')

    plt.xlabel('X1'); plt.ylabel('X2')
    plt.xlim(0.0, 12.)
    plt.ylim(0.0, 12.)
    plt.show()


def loadCircleData(num_data):
    center = np.array([5.0, 5.0])
    radiu_inner = 2
    radiu_outer = 4
    num_inner = num_data / 3
    num_outer = num_data - num_inner

    data = []
    theta = 0.0
    for i in range(num_inner):
        pho = (theta % 360) * math.pi / 180
        tmp = np.zeros(2, np.float32)
        tmp[0] = radiu_inner * math.cos(pho) + np.random.rand(1) + center[0]
        tmp[1] = radiu_inner * math.sin(pho) + np.random.rand(1) + center[1]
        data.append(tmp)
        theta += 2

    theta = 0.0
    for i in range(num_outer):
        pho = (theta % 360) * math.pi / 180
        tmp = np.zeros(2, np.float32)
        tmp[0] = radiu_outer * math.cos(pho) + np.random.rand(1) + center[0]
        tmp[1] = radiu_outer * math.sin(pho) + np.random.rand(1) + center[1]
        data.append(tmp)
        theta += 1

    Mat_Label = np.zeros((2, 2), np.float32)
    Mat_Label[0] = center + np.array([-radiu_inner + 0.5, 0])
    Mat_Label[1] = center + np.array([-radiu_outer + 0.5, 0])
    labels = [0, 1]
    Mat_Unlabel = np.vstack(data)
    return Mat_Label, labels, Mat_Unlabel


def loadBandData(num_unlabel_samples):
    #Mat_Label = np.array([[5.0, 2.], [5.0, 8.0]])
    #labels = [0, 1]
    #Mat_Unlabel = np.array([[5.1, 2.], [5.0, 8.1]])

    Mat_Label = np.array([[5.0, 2.], [5.0, 8.0]])
    labels = [0, 1]
    num_dim = Mat_Label.shape[1]
    Mat_Unlabel = np.zeros((num_unlabel_samples, num_dim), np.float32)
    Mat_Unlabel[:num_unlabel_samples/2, :] = (np.random.rand(num_unlabel_samples/2, num_dim) - 0.5) * np.array([3, 1]) + Mat_Label[0]
    Mat_Unlabel[num_unlabel_samples/2 : num_unlabel_samples, :] = (np.random.rand(num_unlabel_samples/2, num_dim) - 0.5) * np.array([3, 1]) + Mat_Label[1]
    return Mat_Label, labels, Mat_Unlabel


# main function
if __name__ == "__main__":
    num_unlabel_samples = 800
    #Mat_Label, labels, Mat_Unlabel = loadBandData(num_unlabel_samples)
    Mat_Label, labels, Mat_Unlabel = loadCircleData(num_unlabel_samples)

    ## Notice: when use 'rbf' as our kernel, the choice of hyper parameter 'sigma' is very import! It should be
    ## chose according to your dataset, specific the distance of two data points. I think it should ensure that
    ## each point has about 10 knn or w_i,j is large enough. It also influence the speed of converge. So, may be
    ## 'knn' kernel is better!
    #unlabel_data_labels = labelPropagation(Mat_Label, Mat_Unlabel, labels, kernel_type = 'rbf', rbf_sigma = 0.2)
    unlabel_data_labels = labelPropagation(Mat_Label, Mat_Unlabel, labels, kernel_type = 'knn', knn_num_neighbors = 10, max_iter = 400)
    show(Mat_Label, labels, Mat_Unlabel, unlabel_data_labels)
            </textarea>
           </div>
           <div class="crayon-main" style="">
            <table class="crayon-table">
             <tbody>
              <tr class="crayon-row">
               <td class="crayon-nums " data-settings="show">
                <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-1">
                  1
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-2">
                  2
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-3">
                  3
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-4">
                  4
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-5">
                  5
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-6">
                  6
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-7">
                  7
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-8">
                  8
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-9">
                  9
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-10">
                  10
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-11">
                  11
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-12">
                  12
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-13">
                  13
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-14">
                  14
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-15">
                  15
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-16">
                  16
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-17">
                  17
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-18">
                  18
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-19">
                  19
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-20">
                  20
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-21">
                  21
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-22">
                  22
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-23">
                  23
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-24">
                  24
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-25">
                  25
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-26">
                  26
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-27">
                  27
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-28">
                  28
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-29">
                  29
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-30">
                  30
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-31">
                  31
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-32">
                  32
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-33">
                  33
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-34">
                  34
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-35">
                  35
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-36">
                  36
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-37">
                  37
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-38">
                  38
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-39">
                  39
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-40">
                  40
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-41">
                  41
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-42">
                  42
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-43">
                  43
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-44">
                  44
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-45">
                  45
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-46">
                  46
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-47">
                  47
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-48">
                  48
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-49">
                  49
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-50">
                  50
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-51">
                  51
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-52">
                  52
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-53">
                  53
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-54">
                  54
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-55">
                  55
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-56">
                  56
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-57">
                  57
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-58">
                  58
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-59">
                  59
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-60">
                  60
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-61">
                  61
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-62">
                  62
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-63">
                  63
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-64">
                  64
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-65">
                  65
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-66">
                  66
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-67">
                  67
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-68">
                  68
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-69">
                  69
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-70">
                  70
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-71">
                  71
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-72">
                  72
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-73">
                  73
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-74">
                  74
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-75">
                  75
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-76">
                  76
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-77">
                  77
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-78">
                  78
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-79">
                  79
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-80">
                  80
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-81">
                  81
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-82">
                  82
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-83">
                  83
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-84">
                  84
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-85">
                  85
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-86">
                  86
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-87">
                  87
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-88">
                  88
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-89">
                  89
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-90">
                  90
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-91">
                  91
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-92">
                  92
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-93">
                  93
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-94">
                  94
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-95">
                  95
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-96">
                  96
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-97">
                  97
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-98">
                  98
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-99">
                  99
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd777696947794772-100">
                  100
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd777696947794772-101">
                  101
                 </div>
                </div>
               </td>
               <td class="crayon-code">
                <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                 <div class="crayon-line" id="crayon-57685cd777696947794772-1">
                  <span class="crayon-c">
                   #***************************************************************************
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-2">
                  <span class="crayon-c">
                   #*
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-3">
                  <span class="crayon-c">
                   #* Description: label propagation
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-4">
                  <span class="crayon-c">
                   #* Author: Zou Xiaoyi (zouxy09@qq.com)
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-5">
                  <span class="crayon-c">
                   #* Date:   2015-10-15
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-6">
                  <span class="crayon-c">
                   #* HomePage: http://blog.csdn.net/zouxy09
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-7">
                  <span class="crayon-c">
                   #*
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-8">
                  <span class="crayon-c">
                   #**************************************************************************
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-9">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-10">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   time
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-11">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-12">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   numpy
                  </span>
                  <span class="crayon-st">
                   as
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   np
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-13">
                  <span class="crayon-st">
                   from
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   label_propagation
                  </span>
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labelPropagation
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-14">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-15">
                  <span class="crayon-c">
                   # show
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-16">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   show
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_labels
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-17">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   matplotlib
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   pyplot
                  </span>
                  <span class="crayon-st">
                   as
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   plt
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-18">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-19">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   range
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-20">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-21">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   plot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'Dr'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-22">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   elif
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-23">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   plot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'Db'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-24">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   else
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-25">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   plot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'Dy'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-26">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-27">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   range
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-28">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   unlabel_data_labels
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-29">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   plot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'or'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-30">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   elif
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   unlabel_data_labels
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-31">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   plot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'ob'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-32">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   else
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-33">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   plot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'oy'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-34">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-35">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   xlabel
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-s">
                   'X1'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   ylabel
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-s">
                   'X2'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-36">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   xlim
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   0.0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   12.
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-37">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   ylim
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   0.0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   12.
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-38">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   plt
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   show
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-39">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-40">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-41">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   loadCircleData
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_data
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-42">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   array
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   5.0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   5.0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-43">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   radiu_inner
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-44">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   radiu_outer
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   4
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-45">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_inner
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_data
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   3
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-46">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_outer
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_data
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   num_inner
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-47">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-48">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-49">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   theta
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0.0
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-50">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   range
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_inner
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-51">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   pho
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   theta
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   360
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   pi
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   180
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-52">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   zeros
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-53">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   radiu_inner
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   cos
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   pho
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   random
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   rand
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-54">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   radiu_inner
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   sin
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   pho
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   random
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   rand
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-55">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   append
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-56">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   theta
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-57">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-58">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   theta
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0.0
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-59">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   range
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_outer
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-60">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   pho
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   theta
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   360
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   pi
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   180
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-61">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   zeros
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-62">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   radiu_outer
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   cos
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   pho
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   random
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   rand
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-63">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   radiu_outer
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   math
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   sin
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   pho
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   random
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   rand
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-64">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   append
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   tmp
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-65">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   theta
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-66">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-67">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   zeros
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-68">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   array
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-v">
                   radiu_inner
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0.5
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-69">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   center
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   array
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-v">
                   radiu_outer
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0.5
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-70">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-71">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   vstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-72">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   return
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   Mat_Unlabel
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-73">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-74">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-75">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   loadBandData
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-76">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #Mat_Label = np.array([[5.0, 2.], [5.0, 8.0]])
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-77">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #labels = [0, 1]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-78">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #Mat_Unlabel = np.array([[5.1, 2.], [5.0, 8.1]])
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-79">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-80">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   array
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   5.0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   2.
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   5.0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   8.0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-81">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-82">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_dim
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-83">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   zeros
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_dim
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-84">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   random
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   rand
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_dim
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0.5
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   array
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   3
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-85">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   random
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   rand
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_dim
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0.5
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   array
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   3
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-86">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   return
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-87">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-88">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-89">
                  <span class="crayon-c">
                   # main function
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-90">
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   __name__
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "__main__"
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-91">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   800
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-92">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #Mat_Label, labels, Mat_Unlabel = loadBandData(num_unlabel_samples)
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-93">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   loadCircleData
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-94">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-95">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   ## Notice: when use 'rbf' as our kernel, the choice of hyper parameter 'sigma' is very import! It should be
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-96">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   ## chose according to your dataset, specific the distance of two data points. I think it should ensure that
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-97">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   ## each point has about 10 knn or w_i,j is large enough. It also influence the speed of converge. So, may be
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-98">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   ## 'knn' kernel is better!
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-99">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #unlabel_data_labels = labelPropagation(Mat_Label, Mat_Unlabel, labels, kernel_type = 'rbf', rbf_sigma = 0.2)
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd777696947794772-100">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_labels
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   labelPropagation
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   kernel_type
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'knn'
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   10
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   400
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd777696947794772-101">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   show
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_labels
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                </div>
               </td>
              </tr>
             </tbody>
            </table>
           </div>
          </div>
          <!-- [Format Time: 0.1205 seconds] -->
          <p>
          </p>
         </div>
        </div>
       </div>
       <p>
        该注释的，代码都注释的，有看不明白的，欢迎交流。不同迭代次数时候的结果如下：
       </p>
       <p>
        <img src="http://img.blog.csdn.net/20151013215936797?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"/>
       </p>
       <p>
        是不是很漂亮的传播过程？！在数值上也是可以看到随着迭代的进行逐渐收敛的，迭代的数值变化过程如下：
       </p>
       <div class="dp-highlighter bg_python">
        <div class="bar">
         <div class="tools">
          <p>
           <b>
            [python]
           </b>
           <a class="ViewSource" href="http://blog.csdn.net/zouxy09/article/details/49105265" title="view plain">
            view plain
           </a>
           <a class="CopyToClipboard" href="http://blog.csdn.net/zouxy09/article/details/49105265" title="copy">
            copy
           </a>
          </p>
          <div>
           <embed align="middle" height="18" id="ZeroClipboardMovie_3" name="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash" width="18">
           </embed>
          </div>
         </div>
        </div>
        <ol class="dp-py" start="1">
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           0
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1602.000000
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           1
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           6.300182
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           2
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           5.129996
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           3
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           4.301994
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           4
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           3.819295
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           5
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           3.501743
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           6
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           3.277122
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           7
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           3.105952
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           8
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.967030
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           9
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.848606
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           10
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.743997
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           11
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.649270
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           12
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.562057
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           13
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.480885
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           14
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.404774
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           15
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.333075
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           16
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.265301
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           17
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.201107
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           18
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.140209
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           19
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.082354
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           20
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           2.027376
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           21
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.975071
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           22
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.925286
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           23
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.877894
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           24
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.832743
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           25
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.789721
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           26
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.748706
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           27
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.709593
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           28
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.672284
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           29
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.636668
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           30
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.602668
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           31
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.570200
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           32
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.539179
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           33
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.509530
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           34
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.481182
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           35
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.454066
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           36
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.428120
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           37
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.403283
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           38
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.379502
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           39
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.356734
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           40
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.334906
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           41
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.313983
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           42
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.293921
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           43
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.274681
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           44
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.256214
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           45
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.238491
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           46
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.221474
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           47
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.205126
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           48
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.189417
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           49
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.174316
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           50
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.159804
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           51
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.145844
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           52
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.132414
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           53
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.119490
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           54
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.107032
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           55
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.095054
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           56
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.083513
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           57
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.072397
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           58
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.061671
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           59
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.051324
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           60
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.041363
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           61
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.031742
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           62
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.022459
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           63
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.013494
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           64
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           1.004836
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           65
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.996484
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           66
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.988407
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           67
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.980592
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           68
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.973045
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           69
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.965744
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           70
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.958682
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           71
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.951848
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           72
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.945227
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           73
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.938820
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           74
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.932608
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           75
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.926590
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           76
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.920765
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           77
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.915107
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           78
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.909628
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           79
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.904309
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           80
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.899143
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           81
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.894122
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           82
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.889259
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           83
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.884530
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           84
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.879933
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           85
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.875464
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           86
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.871121
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           87
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.866888
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           88
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.862773
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           89
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.858783
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           90
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.854879
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           91
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.851084
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           92
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.847382
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           93
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.843779
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           94
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.840274
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           95
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.836842
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           96
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.833501
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           97
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.830240
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           98
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.827051
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           99
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.823950
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           100
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.820906
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           101
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.817946
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           102
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.815053
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           103
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.812217
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           104
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.809437
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           105
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.806724
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           106
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.804076
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           107
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.801480
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           108
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.798937
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           109
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.796448
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           110
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.794008
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           111
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.791612
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           112
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.789282
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           113
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.786984
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           114
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.784728
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           115
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.782516
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           116
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.780355
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           117
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.778216
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           118
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.776139
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           119
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.774087
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           120
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.772072
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           121
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.770085
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           122
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.768146
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           123
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.766232
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           124
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.764356
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           125
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.762504
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           126
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.760685
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           127
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.758889
          </span>
         </li>
         <li class="alt">
          —&gt; Iteration
          <span class="number">
           128
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.757135
          </span>
         </li>
         <li class="">
          —&gt; Iteration
          <span class="number">
           129
          </span>
          /
          <span class="number">
           400
          </span>
          , changed:
          <span class="number">
           0.755406
          </span>
         </li>
        </ol>
       </div>
       <p>
        <strong>
         四、LP算法MPI并行实现
        </strong>
       </p>
       <p>
        这里，我们测试的是LP的变身版本。从公式，我们可以看到，第二项P
        <sub>
         UL
        </sub>
        Y
        <sub>
         L
        </sub>
        迭代过程并没有发生变化，所以这部分实际上从迭代开始就可以计算好，从而避免重复计算。不过，不管怎样，LP算法都要计算一个UxU的矩阵P
        <sub>
         UU
        </sub>
        和一个UxC矩阵F
        <sub>
         U
        </sub>
        的乘积。当我们的unlabeled数据非常多，而且类别也很多的时候，计算是很慢的，同时占用的内存量也非常大。另外，构造Graph需要计算两两的相似度，也是O(n
        <sup>
         2
        </sup>
        )的复杂度，当我们数据的特征维度很大的时候，这个计算量也是非常客观的。所以我们就得考虑并行处理了。而且最好是能放到集群上并行。那如何并行呢？
       </p>
       <p>
        对算法的并行化，一般分为两种：数据并行和模型并行。
       </p>
       <p>
        数据并行很好理解，就是将数据划分，每个节点只处理一部分数据，例如我们构造图的时候，计算每个数据的k近邻。例如我们有1000个样本和20个CPU 节点，那么就平均分发，让每个CPU节点计算50个样本的k近邻，然后最后再合并大家的结果。可见这个加速比也是非常可观的。
       </p>
       <p>
        模 型并行一般发生在模型很大，无法放到单机的内存里面的时候。例如庞大的深度神经网络训练的时候，就需要把这个网络切开，然后分别求解梯度，最后有个 leader的节点来收集大家的梯度，再反馈给大家去更新。当然了，其中存在更细致和高效的工程处理方法。在我们的LP算法中，也是可以做模型并行的。假 如我们的类别数C很大，把类别数切开，让不同的CPU节点处理，实际上就相当于模型并行了。
       </p>
       <p>
        那为啥不切大矩阵P
        <sub>
         UU
        </sub>
        ，而是切小点的矩阵F
        <sub>
         U
        </sub>
        ，因为大矩阵P
        <sub>
         UU
        </sub>
        没法独立分块，并行的一个原则是处理必须是独立的。 矩阵F
        <sub>
         U
        </sub>
        依赖的是所有的U，而把P
        <sub>
         UU
        </sub>
        切开分发到其他节点的时候，每次F
        <sub>
         U
        </sub>
        的更新都需要和其他的节点通信，这个通信的代价是很大的（实际上，很多并行系统没法达到线性的加速度的瓶颈是通信！线性加速比是，我增加了n台机器，速度就提升了n倍）。但是对类别C也就是矩阵F
        <sub>
         U
        </sub>
        切分，就不会有这个问题，因为他们的计算是独立的。只是决定样本的最终类别的时候，将所有的F
        <sub>
         U
        </sub>
        收集回来求max就可以了。
       </p>
       <p>
        所 以，在下面的代码中，是同时包含了数据并行和模型并行的雏形的。另外，还值得一提的是，我们是迭代算法，那决定什么时候迭代算法停止？除了判断收敛外，我 们还可以让每迭代几步，就用测试label测试一次结果，看模型的整体训练性能如何。特别是判断训练是否过拟合的时候非常有效。因此，代码中包含了这部分 内容。
       </p>
       <p>
        好了，代码终于来了。大家可以搞点大数据库来测试，如果有MPI集群条件的话就更好了。
       </p>
       <p>
        下面的代码依赖numpy、scipy（用其稀疏矩阵加速计算）和mpi4py。其中mpi4py需要依赖openmpi和Cpython，可以参考我
        <a href="http://blog.csdn.net/zouxy09/article/details/49031845" target="_blank">
         之前的博客
        </a>
        进行安装。
       </p>
       <div class="dp-highlighter bg_python">
        <div class="bar">
         <div class="tools">
          <p>
           <b>
            [python]
           </b>
           <a class="ViewSource" href="http://blog.csdn.net/zouxy09/article/details/49105265" title="view plain">
            view plain
           </a>
           <a class="CopyToClipboard" href="http://blog.csdn.net/zouxy09/article/details/49105265" title="copy">
            copy
           </a>
          </p>
          <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
          <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685cd7776bd672691620" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
           <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <span class="crayon-title">
            </span>
            <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
             <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-wrap-button" title="切换自动换行">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-expand-button" title="点击展开代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-copy-button" title="复制代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
              <div class="crayon-button-icon">
              </div>
             </div>
             <span class="crayon-language">
              Python
             </span>
            </div>
           </div>
           <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
           </div>
           <div class="crayon-plain-wrap">
            <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
             #***************************************************************************
#* 
#* Description: label propagation
#* Author: Zou Xiaoyi (zouxy09@qq.com)
#* Date:   2015-10-15
#* HomePage: http://blog.csdn.net/zouxy09
#* 
#**************************************************************************

import os, sys, time
import numpy as np
from scipy.sparse import csr_matrix, lil_matrix, eye
import operator
import cPickle as pickle
import mpi4py.MPI as MPI

#
#   Global variables for MPI
#

# instance for invoking MPI related functions
comm = MPI.COMM_WORLD
# the node rank in the whole community
comm_rank = comm.Get_rank()
# the size of the whole community, i.e., the total number of working nodes in the MPI cluster
comm_size = comm.Get_size()

# load mnist dataset
def load_MNIST():
    import gzip
    f = gzip.open("mnist.pkl.gz", "rb")
    train, val, test = pickle.load(f)
    f.close()

    Mat_Label = train[0]
    labels = train[1]
    Mat_Unlabel = test[0]
    groundtruth = test[1]
    labels_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

    return Mat_Label, labels, labels_id, Mat_Unlabel, groundtruth

# return k neighbors index
def navie_knn(dataSet, query, k):
    numSamples = dataSet.shape[0]

    ## step 1: calculate Euclidean distance
    diff = np.tile(query, (numSamples, 1)) - dataSet
    squaredDiff = diff ** 2
    squaredDist = np.sum(squaredDiff, axis = 1) # sum is performed by row

    ## step 2: sort the distance
    sortedDistIndices = np.argsort(squaredDist)
    if k &gt; len(sortedDistIndices):
        k = len(sortedDistIndices)
    return sortedDistIndices[0:k]


# build a big graph (normalized weight matrix)
# sparse U x (U + L) matrix
def buildSubGraph(Mat_Label, Mat_Unlabel, knn_num_neighbors):
    num_unlabel_samples = Mat_Unlabel.shape[0]
    data = []; indices = []; indptr = [0]
    Mat_all = np.vstack((Mat_Label, Mat_Unlabel))
    values = np.ones(knn_num_neighbors, np.float32) / knn_num_neighbors
    for i in xrange(num_unlabel_samples):
        k_neighbors = navie_knn(Mat_all, Mat_Unlabel[i, :], knn_num_neighbors)
        indptr.append(np.int32(indptr[-1]) + knn_num_neighbors)
        indices.extend(k_neighbors)
        data.append(values)
    return csr_matrix((np.hstack(data), indices, indptr))


# build a big graph (normalized weight matrix)
# sparse U x (U + L) matrix
def buildSubGraph_MPI(Mat_Label, Mat_Unlabel, knn_num_neighbors):
    num_unlabel_samples = Mat_Unlabel.shape[0]
    local_data = []; local_indices = []; local_indptr = [0]
    Mat_all = np.vstack((Mat_Label, Mat_Unlabel))
    values = np.ones(knn_num_neighbors, np.float32) / knn_num_neighbors
    sample_offset = np.linspace(0, num_unlabel_samples, comm_size + 1).astype('int')
    for i in range(sample_offset[comm_rank], sample_offset[comm_rank+1]):
        k_neighbors = navie_knn(Mat_all, Mat_Unlabel[i, :], knn_num_neighbors)
        local_indptr.append(np.int32(local_indptr[-1]) + knn_num_neighbors)
        local_indices.extend(k_neighbors)
        local_data.append(values)
    data = np.hstack(comm.allgather(local_data))
    indices = np.hstack(comm.allgather(local_indices))
    indptr_tmp = comm.allgather(local_indptr)
    indptr = []
    for i in range(len(indptr_tmp)):
        if i == 0:
            indptr.extend(indptr_tmp[i])
        else:
            last_indptr = indptr[-1]
            del(indptr[-1])
            indptr.extend(indptr_tmp[i] + last_indptr)
    return csr_matrix((np.hstack(data), indices, indptr), dtype = np.float32)


# label propagation
def run_label_propagation_sparse(knn_num_neighbors = 20, max_iter = 100, tol = 1e-4, test_per_iter = 1):
    # load data and graph
    print "Processor %d/%d loading graph file..." % (comm_rank, comm_size)
    #Mat_Label, labels, Mat_Unlabel, groundtruth = loadFourBandData()
    Mat_Label, labels, labels_id, Mat_Unlabel, unlabel_data_id = load_MNIST()
    if comm_size &gt; len(labels_id):
        raise ValueError("Sorry, the processors must be less than the number of classes")
    #affinity_matrix = buildSubGraph(Mat_Label, Mat_Unlabel, knn_num_neighbors)
    affinity_matrix = buildSubGraph_MPI(Mat_Label, Mat_Unlabel, knn_num_neighbors)

    # get some parameters
    num_classes = len(labels_id)
    num_label_samples = len(labels)
    num_unlabel_samples = Mat_Unlabel.shape[0]

    affinity_matrix_UL = affinity_matrix[:, 0:num_label_samples]
    affinity_matrix_UU = affinity_matrix[:, num_label_samples:num_label_samples+num_unlabel_samples]

    if comm_rank == 0:
        print "Have %d labeled images, %d unlabeled images and %d classes" % (num_label_samples, num_unlabel_samples, num_classes)

    # divide label_function_U and label_function_L to all processors
    class_offset = np.linspace(0, num_classes, comm_size + 1).astype('int')

    # initialize local label_function_U
    local_start_class = class_offset[comm_rank]
    local_num_classes = class_offset[comm_rank+1] - local_start_class
    local_label_function_U = eye(num_unlabel_samples, local_num_classes, 0, np.float32, format='csr')

    # initialize local label_function_L
    local_label_function_L = lil_matrix((num_label_samples, local_num_classes), dtype = np.float32)
    for i in xrange(num_label_samples):
        class_off = int(labels[i]) - local_start_class
        if class_off &gt;= 0 and class_off &lt; local_num_classes:
            local_label_function_L[i, class_off] = 1.0
    local_label_function_L = local_label_function_L.tocsr()
    local_label_info = affinity_matrix_UL.dot(local_label_function_L)
    print "Processor %d/%d has to process %d classes..." % (comm_rank, comm_size, local_label_function_L.shape[1])

    # start to propagation
    iter = 1; changed = 100.0;
    evaluation(num_unlabel_samples, local_start_class, local_label_function_U, unlabel_data_id, labels_id)
    while True:
        pre_label_function = local_label_function_U.copy()

        # propagation
        local_label_function_U = affinity_matrix_UU.dot(local_label_function_U) + local_label_info

        # check converge
        local_changed = abs(pre_label_function - local_label_function_U).sum()
        changed = comm.reduce(local_changed, root = 0, op = MPI.SUM)
        status = 'RUN'
        test = False
        if comm_rank == 0:
            if iter % 1 == 0:
                norm_changed = changed / (num_unlabel_samples * num_classes)
                print "---&gt; Iteration %d/%d, changed: %f" % (iter, max_iter, norm_changed)
            if iter &gt;= max_iter or changed &lt; tol:
                status = 'STOP'
                print "************** Iteration over! ****************"
            if iter % test_per_iter == 0:
                test = True
            iter += 1
        test = comm.bcast(test if comm_rank == 0 else None, root = 0)
        status = comm.bcast(status if comm_rank == 0 else None, root = 0)
        if status == 'STOP':
            break
        if test == True:
            evaluation(num_unlabel_samples, local_start_class, local_label_function_U, unlabel_data_id, labels_id)
    evaluation(num_unlabel_samples, local_start_class, local_label_function_U, unlabel_data_id, labels_id)


def evaluation(num_unlabel_samples, local_start_class, local_label_function_U, unlabel_data_id, labels_id):
    # get local label with max score
    if comm_rank == 0:
        print "Start to combine local result..."
    local_max_score = np.zeros((num_unlabel_samples, 1), np.float32)
    local_max_label = np.zeros((num_unlabel_samples, 1), np.int32)
    for i in xrange(num_unlabel_samples):
        local_max_label[i, 0] = np.argmax(local_label_function_U.getrow(i).todense())
        local_max_score[i, 0] = local_label_function_U[i, local_max_label[i, 0]]
        local_max_label[i, 0] += local_start_class

    # gather the results from all the processors
    if comm_rank == 0:
        print "Start to gather results from all processors"
    all_max_label = np.hstack(comm.allgather(local_max_label))
    all_max_score = np.hstack(comm.allgather(local_max_score))

    # get terminate label of unlabeled data
    if comm_rank == 0:
        print "Start to analysis the results..."
        right_predict_count = 0
        for i in xrange(num_unlabel_samples):
            if i % 1000 == 0:
                print "***", all_max_score[i]
            max_idx = np.argmax(all_max_score[i])
            max_label = all_max_label[i, max_idx]
            if int(unlabel_data_id[i]) == int(labels_id[max_label]):
                right_predict_count += 1
        accuracy = float(right_predict_count) * 100.0 / num_unlabel_samples
        print "Have %d samples, accuracy: %.3f%%!" % (num_unlabel_samples, accuracy)


if __name__ == '__main__':
    run_label_propagation_sparse(knn_num_neighbors = 20, max_iter = 30)
            </textarea>
           </div>
           <div class="crayon-main" style="">
            <table class="crayon-table">
             <tbody>
              <tr class="crayon-row">
               <td class="crayon-nums " data-settings="show">
                <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-1">
                  1
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-2">
                  2
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-3">
                  3
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-4">
                  4
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-5">
                  5
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-6">
                  6
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-7">
                  7
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-8">
                  8
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-9">
                  9
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-10">
                  10
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-11">
                  11
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-12">
                  12
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-13">
                  13
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-14">
                  14
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-15">
                  15
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-16">
                  16
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-17">
                  17
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-18">
                  18
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-19">
                  19
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-20">
                  20
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-21">
                  21
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-22">
                  22
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-23">
                  23
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-24">
                  24
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-25">
                  25
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-26">
                  26
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-27">
                  27
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-28">
                  28
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-29">
                  29
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-30">
                  30
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-31">
                  31
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-32">
                  32
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-33">
                  33
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-34">
                  34
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-35">
                  35
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-36">
                  36
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-37">
                  37
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-38">
                  38
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-39">
                  39
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-40">
                  40
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-41">
                  41
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-42">
                  42
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-43">
                  43
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-44">
                  44
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-45">
                  45
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-46">
                  46
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-47">
                  47
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-48">
                  48
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-49">
                  49
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-50">
                  50
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-51">
                  51
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-52">
                  52
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-53">
                  53
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-54">
                  54
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-55">
                  55
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-56">
                  56
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-57">
                  57
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-58">
                  58
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-59">
                  59
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-60">
                  60
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-61">
                  61
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-62">
                  62
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-63">
                  63
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-64">
                  64
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-65">
                  65
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-66">
                  66
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-67">
                  67
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-68">
                  68
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-69">
                  69
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-70">
                  70
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-71">
                  71
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-72">
                  72
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-73">
                  73
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-74">
                  74
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-75">
                  75
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-76">
                  76
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-77">
                  77
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-78">
                  78
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-79">
                  79
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-80">
                  80
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-81">
                  81
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-82">
                  82
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-83">
                  83
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-84">
                  84
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-85">
                  85
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-86">
                  86
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-87">
                  87
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-88">
                  88
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-89">
                  89
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-90">
                  90
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-91">
                  91
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-92">
                  92
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-93">
                  93
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-94">
                  94
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-95">
                  95
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-96">
                  96
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-97">
                  97
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-98">
                  98
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-99">
                  99
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-100">
                  100
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-101">
                  101
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-102">
                  102
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-103">
                  103
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-104">
                  104
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-105">
                  105
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-106">
                  106
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-107">
                  107
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-108">
                  108
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-109">
                  109
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-110">
                  110
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-111">
                  111
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-112">
                  112
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-113">
                  113
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-114">
                  114
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-115">
                  115
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-116">
                  116
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-117">
                  117
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-118">
                  118
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-119">
                  119
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-120">
                  120
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-121">
                  121
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-122">
                  122
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-123">
                  123
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-124">
                  124
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-125">
                  125
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-126">
                  126
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-127">
                  127
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-128">
                  128
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-129">
                  129
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-130">
                  130
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-131">
                  131
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-132">
                  132
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-133">
                  133
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-134">
                  134
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-135">
                  135
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-136">
                  136
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-137">
                  137
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-138">
                  138
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-139">
                  139
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-140">
                  140
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-141">
                  141
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-142">
                  142
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-143">
                  143
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-144">
                  144
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-145">
                  145
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-146">
                  146
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-147">
                  147
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-148">
                  148
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-149">
                  149
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-150">
                  150
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-151">
                  151
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-152">
                  152
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-153">
                  153
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-154">
                  154
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-155">
                  155
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-156">
                  156
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-157">
                  157
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-158">
                  158
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-159">
                  159
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-160">
                  160
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-161">
                  161
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-162">
                  162
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-163">
                  163
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-164">
                  164
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-165">
                  165
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-166">
                  166
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-167">
                  167
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-168">
                  168
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-169">
                  169
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-170">
                  170
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-171">
                  171
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-172">
                  172
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-173">
                  173
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-174">
                  174
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-175">
                  175
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-176">
                  176
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-177">
                  177
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-178">
                  178
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-179">
                  179
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-180">
                  180
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-181">
                  181
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-182">
                  182
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-183">
                  183
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-184">
                  184
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-185">
                  185
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-186">
                  186
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-187">
                  187
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-188">
                  188
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-189">
                  189
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-190">
                  190
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-191">
                  191
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-192">
                  192
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-193">
                  193
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-194">
                  194
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-195">
                  195
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-196">
                  196
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-197">
                  197
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-198">
                  198
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-199">
                  199
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-200">
                  200
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-201">
                  201
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-202">
                  202
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-203">
                  203
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-204">
                  204
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-205">
                  205
                 </div>
                 <div class="crayon-num crayon-striped-num" data-line="crayon-57685cd7776bd672691620-206">
                  206
                 </div>
                 <div class="crayon-num" data-line="crayon-57685cd7776bd672691620-207">
                  207
                 </div>
                </div>
               </td>
               <td class="crayon-code">
                <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-1">
                  <span class="crayon-c">
                   #***************************************************************************
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-2">
                  <span class="crayon-c">
                   #*
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-3">
                  <span class="crayon-c">
                   #* Description: label propagation
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-4">
                  <span class="crayon-c">
                   #* Author: Zou Xiaoyi (zouxy09@qq.com)
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-5">
                  <span class="crayon-c">
                   #* Date:   2015-10-15
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-6">
                  <span class="crayon-c">
                   #* HomePage: http://blog.csdn.net/zouxy09
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-7">
                  <span class="crayon-c">
                   #*
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-8">
                  <span class="crayon-c">
                   #**************************************************************************
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-9">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-10">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   os
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   sys
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   time
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-11">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   numpy
                  </span>
                  <span class="crayon-st">
                   as
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   np
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-12">
                  <span class="crayon-st">
                   from
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   scipy
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   sparse
                  </span>
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   csr_matrix
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   lil_matrix
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   eye
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-13">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   operator
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-14">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   cPickle
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   as
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   pickle
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-15">
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   mpi4py
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   MPI
                  </span>
                  <span class="crayon-st">
                   as
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   MPI
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-16">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-17">
                  <span class="crayon-c">
                   #
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-18">
                  <span class="crayon-c">
                   #   Global variables for MPI
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-19">
                  <span class="crayon-c">
                   #
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-20">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-21">
                  <span class="crayon-c">
                   # instance for invoking MPI related functions
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-22">
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   MPI
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   COMM_WORLD
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-23">
                  <span class="crayon-c">
                   # the node rank in the whole community
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-24">
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   Get_rank
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-25">
                  <span class="crayon-c">
                   # the size of the whole community, i.e., the total number of working nodes in the MPI cluster
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-26">
                  <span class="crayon-v">
                   comm_size
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   Get_size
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-27">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-28">
                  <span class="crayon-c">
                   # load mnist dataset
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-29">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   load_MNIST
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-30">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-r">
                   import
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   gzip
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-31">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   f
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   gzip
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   open
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-s">
                   "mnist.pkl.gz"
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "rb"
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-32">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   train
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   val
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   pickle
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   load
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   f
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-33">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   f
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   close
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-34">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-35">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   train
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-36">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   train
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-37">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-38">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   groundtruth
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-39">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   3
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   4
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   5
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   6
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   7
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   8
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   9
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-40">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-41">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   return
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   groundtruth
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-42">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-43">
                  <span class="crayon-c">
                   # return k neighbors index
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-44">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   navie_knn
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   dataSet
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   query
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   k
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-45">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   numSamples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   dataSet
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-46">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-47">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   ## step 1: calculate Euclidean distance
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-48">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   diff
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   tile
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   query
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   numSamples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   dataSet
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-49">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-v">
                   squaredDiff
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   diff
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   2
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-50">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   squaredDist
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   sum
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   squaredDiff
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   axis
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # sum is performed by row
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-51">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-52">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   ## step 2: sort the distance
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-53">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   sortedDistIndices
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   argsort
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   squaredDist
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-54">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   k
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   &gt;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   len
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   sortedDistIndices
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-55">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   k
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   len
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   sortedDistIndices
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-56">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   return
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   sortedDistIndices
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-v">
                   k
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-57">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-58">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-59">
                  <span class="crayon-c">
                   # build a big graph (normalized weight matrix)
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-60">
                  <span class="crayon-c">
                   # sparse U x (U + L) matrix
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-61">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   buildSubGraph
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-62">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-63">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indices
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-64">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_all
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   vstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-65">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   values
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   ones
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   knn_num_neighbors
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-66">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   xrange
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-67">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   k_neighbors
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   navie_knn
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_all
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-68">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   append
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   int32
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-69">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indices
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   extend
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   k_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-70">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   append
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   values
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-71">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   return
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   csr_matrix
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   hstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indices
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-72">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-73">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-74">
                  <span class="crayon-c">
                   # build a big graph (normalized weight matrix)
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-75">
                  <span class="crayon-c">
                   # sparse U x (U + L) matrix
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-76">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   buildSubGraph_MPI
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-77">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-78">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_data
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_indices
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_indptr
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-79">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_all
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   vstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-80">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   values
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   ones
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   knn_num_neighbors
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-81">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-v">
                   sample_offset
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   linspace
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_size
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   astype
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-s">
                   'int'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-82">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   range
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   sample_offset
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   sample_offset
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-83">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   k_neighbors
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   navie_knn
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_all
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-84">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_indptr
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   append
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   int32
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_indptr
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-85">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_indices
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   extend
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   k_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-86">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_data
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   append
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   values
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-87">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   hstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   allgather
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_data
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-88">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indices
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   hstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   allgather
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_indices
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-89">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr_tmp
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   allgather
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_indptr
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-90">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-91">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   range
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-k ">
                   len
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   indptr_tmp
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-92">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-93">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   extend
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   indptr_tmp
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-94">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   else
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-95">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   last_indptr
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-96">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-r">
                   del
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-97">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   extend
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   indptr_tmp
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   last_indptr
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-98">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   return
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   csr_matrix
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   hstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   data
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indices
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   indptr
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   dtype
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-99">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-100">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-101">
                  <span class="crayon-c">
                   # label propagation
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-102">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   run_label_propagation_sparse
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   20
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   100
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tol
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1e
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-cn">
                   4
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   test_per_iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-103">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # load data and graph
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-104">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Processor %d/%d loading graph file..."
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_size
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-105">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #Mat_Label, labels, Mat_Unlabel, groundtruth = loadFourBandData()
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-106">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_id
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   load_MNIST
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-107">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_size
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   &gt;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   len
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-108">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   raise
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   ValueError
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-s">
                   "Sorry, the processors must be less than the number of classes"
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-109">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   #affinity_matrix = buildSubGraph(Mat_Label, Mat_Unlabel, knn_num_neighbors)
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-110">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   buildSubGraph_MPI
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   Mat_Label
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-111">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-112">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # get some parameters
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-113">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_classes
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   len
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-114">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   len
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-115">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   Mat_Unlabel
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-116">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-117">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix_UL
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-118">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix_UU
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-119">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-120">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-121">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Have %d labeled images, %d unlabeled images and %d classes"
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_classes
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-122">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-123">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # divide label_function_U and label_function_L to all processors
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-124">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_offset
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   linspace
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_classes
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_size
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   astype
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-s">
                   'int'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-125">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-126">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # initialize local label_function_U
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-127">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_start_class
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_offset
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-128">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_num_classes
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_offset
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   local_start_class
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-129">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   eye
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_num_classes
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   format
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-s">
                   'csr'
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-130">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-131">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # initialize local label_function_L
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-132">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_L
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   lil_matrix
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_num_classes
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   dtype
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-133">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   xrange
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_label_samples
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-134">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_off
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   local_start_class
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-135">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_off
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   &gt;=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   and
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_off
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   &lt;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_num_classes
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-136">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_L
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   class_off
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1.0
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-137">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_L
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_L
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   tocsr
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-138">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_info
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix_UL
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   dot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_label_function_L
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-139">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Processor %d/%d has to process %d classes..."
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_size
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_L
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   shape
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-140">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-141">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # start to propagation
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-142">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   changed
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   100.0
                  </span>
                  <span class="crayon-sy">
                   ;
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-143">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   evaluation
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_start_class
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_id
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-144">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   while
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-t">
                   True
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-145">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   pre_label_function
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   copy
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-146">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-147">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # propagation
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-148">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   affinity_matrix_UU
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   dot
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_info
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-149">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-150">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # check converge
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-151">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_changed
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   abs
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   pre_label_function
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   -
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   sum
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-152">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   changed
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   reduce
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_changed
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   root
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   op
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   MPI
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-k ">
                   SUM
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-153">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   status
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'RUN'
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-154">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-t">
                   False
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-155">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-156">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-157">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   norm_changed
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   changed
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   num_classes
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-158">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "---&gt; Iteration %d/%d, changed: %f"
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-k ">
                   iter
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_iter
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   norm_changed
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-159">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   &gt;=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   max_iter
                  </span>
                  <span class="crayon-st">
                   or
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   changed
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   &lt;
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   tol
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-160">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   status
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'STOP'
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-161">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "************** Iteration over! ****************"
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-162">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   test_per_iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-163">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-t">
                   True
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-164">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-165">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   bcast
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   else
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-t">
                   None
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   root
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-166">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   status
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   bcast
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-e">
                   status
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   else
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-t">
                   None
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   root
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-167">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   status
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   'STOP'
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-168">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   break
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-169">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   test
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-t">
                   True
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-170">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   evaluation
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_start_class
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_id
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-171">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   evaluation
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_start_class
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_id
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-172">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-173">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-174">
                  <span class="crayon-r">
                   def
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   evaluation
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_start_class
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   unlabel_data_id
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-175">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # get local label with max score
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-176">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-177">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Start to combine local result..."
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-178">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_max_score
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   zeros
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   float32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-179">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_max_label
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   zeros
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-v">
                   int32
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-180">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   xrange
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-181">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_max_label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   argmax
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   getrow
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   todense
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-182">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_max_score
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_label_function_U
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_max_label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-183">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_max_label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   local_start_class
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-184">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-185">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # gather the results from all the processors
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-186">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-187">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Start to gather results from all processors"
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-188">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   all_max_label
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   hstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   allgather
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_max_label
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-189">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   all_max_score
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   hstack
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   comm
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   allgather
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   local_max_score
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-190">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-191">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-c">
                   # get terminate label of unlabeled data
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-192">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   comm_rank
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-193">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Start to analysis the results..."
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-194">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   right_predict_count
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-195">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   for
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-i">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   in
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   xrange
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-196">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1000
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   0
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-197">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "***"
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   all_max_score
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-198">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_idx
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   np
                  </span>
                  <span class="crayon-sy">
                   .
                  </span>
                  <span class="crayon-e">
                   argmax
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   all_max_score
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-199">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_label
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   all_max_label
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_idx
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-200">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   unlabel_data_id
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   i
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   int
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   labels_id
                  </span>
                  <span class="crayon-sy">
                   [
                  </span>
                  <span class="crayon-v">
                   max_label
                  </span>
                  <span class="crayon-sy">
                   ]
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-201">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   right_predict_count
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   +=
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   1
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-202">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   accuracy
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-k ">
                   float
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   right_predict_count
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   *
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   100.0
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   /
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   num_unlabel_samples
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-203">
                  <span class="crayon-e">
                  </span>
                  <span class="crayon-k ">
                   print
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   "Have %d samples, accuracy: %.3f%%!"
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   %
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   num_unlabel_samples
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   accuracy
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-204">
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-205">
                 </div>
                 <div class="crayon-line crayon-striped-line" id="crayon-57685cd7776bd672691620-206">
                  <span class="crayon-st">
                   if
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   __name__
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   ==
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-s">
                   '__main__'
                  </span>
                  <span class="crayon-o">
                   :
                  </span>
                 </div>
                 <div class="crayon-line" id="crayon-57685cd7776bd672691620-207">
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-e">
                   run_label_propagation_sparse
                  </span>
                  <span class="crayon-sy">
                   (
                  </span>
                  <span class="crayon-v">
                   knn_num_neighbors
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   20
                  </span>
                  <span class="crayon-sy">
                   ,
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-v">
                   max_iter
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-o">
                   =
                  </span>
                  <span class="crayon-h">
                  </span>
                  <span class="crayon-cn">
                   30
                  </span>
                  <span class="crayon-sy">
                   )
                  </span>
                 </div>
                </div>
               </td>
              </tr>
             </tbody>
            </table>
           </div>
          </div>
          <!-- [Format Time: 0.1840 seconds] -->
          <p>
          </p>
         </div>
        </div>
       </div>
       <p>
        <strong>
         五、参考资料
        </strong>
       </p>
       <p>
        [1]
        <a href="http://pages.cs.wisc.edu/%7Ejerryzhu/pub/thesis.pdf" target="_blank">
         Semi-SupervisedLearning with Graphs.pdf
        </a>
       </p>
       <p>
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24663.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/095356be8cb4z9ke9389kd-204x200.jpeg"/>
        </a>
        <a class="link" href="http://dataunion.org/24663.html" rel="bookmark" title="人工智能界最强大脑畅谈AI未来之路">
         人工智能界最强大脑畅谈AI未来之路
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24652.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/02/20150522141422337-265x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24652.html" rel="bookmark" title="重磅 | MIT与谷歌专家合著论文：机器学习和神经科学的相互启发与融合（附论文）">
         重磅 | MIT与谷歌专家合著论文：机器学习和神经科学的相互启发与融合（附论文）
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24616.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/224806wllbe6tcimyyi9xt-300x167.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24616.html" rel="bookmark" title="微软人工智能计划背后的华人力量">
         微软人工智能计划背后的华人力量
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24562.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/8aac7ceb921d1684f06e6f65e2c1f224-300x173.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24562.html" rel="bookmark" title="各位大佬，别再拿人工智能当春药了！">
         各位大佬，别再拿人工智能当春药了！
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F21096.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/21096.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/21096.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>